<template>
	<view class="modal" v-if="isVisible">
		<view class="modal-content">
			<text class="modal-title">提示</text>
			<text class="modal-message">{{ message }}</text>
			<view class="modal-buttons">
				<button class="modal-cancel" @tap="cancel">取消</button>
				<button class="modal-confirm" @tap="confirm">确定</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			isVisible: Boolean,
			message: {
				type: String,
				default: '确定要执行此操作吗？'
			}
		},
		methods: {
			cancel() {
				this.$emit('cancel');
			},
			confirm() {
				this.$emit('confirm');
				uni.navigateBack();
			}
		}
	};
</script>

<style>
	.modal {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.4);
		display: flex;
		justify-content: center;
		align-items: center;
		backdrop-filter: blur(5px);
		z-index: 100;
	}

	.modal-content {
		background: #fff;
		padding: 50rpx;
		border-radius: 20rpx;
		width: 80%;
		text-align: center;
		box-shadow: 0px 4rpx 10rpx rgba(0, 0, 0, 0.2);
		animation: fadeIn 0.3s ease-in-out;
	}

	.modal-title {
		font-size: 34rpx;
		font-weight: bold;
		color: #333;
		margin-bottom: 20rpx;
		display: block;
	}

	.modal-message {
		font-size: 28rpx;
		color: #555;
		margin-bottom: 60rpx;
		display: block;
	}

	.modal-buttons {
		display: flex;
		justify-content: space-between;
		gap: 20rpx;
	}

	.modal-cancel,
	.modal-confirm {
		flex: 1;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 30rpx;
		border-radius: 12rpx;
		text-align: center;
		font-weight: bold;
		cursor: pointer;
		transition: all 0.3s;
	}

	.modal-cancel {
		background-color: #ddd;
		color: #333;
	}

	.modal-cancel:hover {
		background-color: #ccc;
	}

	.modal-confirm {
		background-color: #007aff;
		color: #fff;
	}

	.modal-confirm:hover {
		background-color: #005ecb;
	}

	@keyframes fadeIn {
		from {
			opacity: 0;
			transform: scale(0.9);
		}

		to {
			opacity: 1;
			transform: scale(1);
		}
	}
</style>